package pl.edu.mimuw.irs.rcp.controller.factory;

import org.eclipse.gef.EditPart;

import pl.edu.mimuw.irs.core.model.petrinet.Arc;
import pl.edu.mimuw.irs.core.model.petrinet.Place;
import pl.edu.mimuw.irs.core.model.petrinet.Transition;
import pl.edu.mimuw.irs.core.model.petrinet.workflow.Workflow;
import pl.edu.mimuw.irs.rcp.controller.part.ArcEditPart;
import pl.edu.mimuw.irs.rcp.controller.part.TGPlaceEditPart;
import pl.edu.mimuw.irs.rcp.controller.part.TGTransitionEditPart;
import pl.edu.mimuw.irs.rcp.controller.part.WorkflowEditPart;

/**
 * @author Jakub Rauch
 * Created on: 2009-05-16
 */
public class TGEditPartFactory implements org.eclipse.gef.EditPartFactory {
	
	// *** Attributes

	// *** Methods
	
	@Override
	public EditPart createEditPart(EditPart context, Object model) {
		EditPart editPart = null;
		if(model instanceof Place){
			//Standard edit part instance for IRSPlace element
			editPart = new TGPlaceEditPart();
			editPart.setModel(model);
		} else if(model instanceof Transition){
			//Standard edit part instance for IRSTransition element
			editPart = new TGTransitionEditPart();
			editPart.setModel(model);
		} else if(model instanceof Arc){
			//Standard edit part instance for IRSArc element
			editPart = new ArcEditPart();
			editPart.setModel(model);
		} else if(model instanceof Workflow){
			//Standard edit part instance for IRSArc element
			editPart = new WorkflowEditPart();
			editPart.setModel(model);
		}
		return editPart;
	}
}
